// util.h
#ifndef _UTIL_H_
#define _UTIL_H_

#include <stdio.h>
#include <stdlib.h>

#define ARGS_CHECK(argc, val)                            \
    do {                                                 \
        if ((argc) != (val)) {                           \
            fprintf(stderr, "Usage: %s ...\n", argv[0]); \
            exit(EXIT_FAILURE);                          \
        }                                                \
    } while (0)

#define ERROR_CHECK(ret, retval, msg) \
    do { \
        if ((ret) == (retval)) { \
            perror(msg); \
            exit(EXIT_FAILURE); \
        } \
    } while (0)

#endif // _UTIL_H_
